package models

import (
	"driver_srv/basic/config"
	"time"
)

// 银行账户表
type BankAccount struct {
	Id             uint32    `gorm:"column:id;type:int UNSIGNED;primaryKey;not null;" json:"id"`
	DriverId       uint32    `gorm:"column:driver_id;type:int UNSIGNED;comment:司机ID;not null;" json:"driver_id"`             // 司机ID
	BankName       string    `gorm:"column:bank_name;type:varchar(100);comment:开户行;not null;" json:"bank_name"`              // 开户行
	BankCardNumber string    `gorm:"column:bank_card_number;type:varchar(50);comment:银行卡;not null;" json:"bank_card_number"` // 银行卡
	CreatedAt      time.Time `gorm:"column:created_at;type:datetime;not null;default:CURRENT_TIMESTAMP;" json:"created_at"`
}

func (b *BankAccount) TableName() string {
	return "bank_account"
}
func (b *BankAccount) BankAccountCreate() error {
	return config.DB.Create(&b).Error
}

// 根据司机ID获取银行账户信息
func (b *BankAccount) FindBankAccountByDriverId() error {
	return config.DB.Where("driver_id = ?", b.DriverId).First(b).Error
}
